# $Id$
# Maintainer: Juergen Hoetzel <juergen@archlinux.org>

pkgname=licq
pkgver=1.8.2
pkgrel=18
pkgdesc="Advanced graphical ICQ clone and more for Unix"
arch=('i686' 'x86_64')
url="http://www.licq.org"
license=('GPL')
depends=('boost-libs' 'gpgme' 'libxss' 'qt4' 'openssl-1.0')
makedepends=('cmake' 'boost' 'optipng')
source=(http://downloads.sourceforge.net/sourceforge/licq/licq-${pkgver}.tar.bz2 licq-gcc6.patch)
md5sums=('46af2bc95865ee61a103d27812fe6e6a'
         '8af303d8d31573246470f0ba0ccba428')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  mkdir build

  # Fix invalid PNG images to work with libpng 1.6
  # https://github.com/licq-im/licq/pull/32
  optipng -quiet -force -fix plugins/qt4-gui/share/skins/Mirabilis/*.png

  # Fix build with GCC 6
  patch -p1 -i ../licq-gcc6.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  local licq_plugins="auto-reply icq rms msn qt4-gui" # osd jabber aosd
  
  local plugins="" _plugin
  for _plugin in ${licq_plugins}; do
    plugins+=" ${_plugin}\/CMakeLists.txt"
  done
  sed -i -e "s/file(GLOB cmake_plugins.*$/set(cmake_plugins ${plugins})/" plugins/CMakeLists.txt

  cd build
  cmake -DCMAKE_INSTALL_PREFIX=/usr -DUSE_FIFO=ON -DBUILD_PLUGINS=ON -DBUILD_TESTS=OFF \
        -DOPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0 \
        -DOPENSSL_SSL_LIBRARY=/usr/lib/openssl-1.0/libssl.so \
        -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/openssl-1.0/libcrypto.so \
        ..
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}/build"
  make DESTDIR="${pkgdir}" install
}
